package model;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class Input {

    public ArrayList<Element> parseData(File f) {
        ArrayList<Element> myObjects = new ArrayList<Element>();
        try {
            Scanner input = new Scanner(f);
            while(input.hasNext()) {
                Scanner line = new Scanner(input.nextLine());
                if(line.hasNext()) {
                    String name = line.next();
                    int ID = line.nextInt();
                    double data = line.nextDouble();
                    myObjects.add(new Element(name, ID, data));
                }
            }
        }
        catch (FileNotFoundException e) {
            // should not happen because File came from user selection
            e.printStackTrace();
        }
        return myObjects;
    }
}
